package cyou.breathe.dynamictp.config.nacos.cloud.starter.configuration;

import cyou.breathe.dynamictp.config.nacos.cloud.starter.refresher.NacosCloudRefresherHandler;
import cyou.breathe.dynamictp.core.notification.service.NotifierDispatcher;
import cyou.breathe.dynamictp.core.config.BootstrapConfigProperties;
import cyou.breathe.dynamictp.spring.base.enable.MarkerConfiguration;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;

/**
 * Nacos Cloud 版本自动装配
 * @author: breathe
 * @createTime: 2025-09-14
 */
@Configurable
@ConditionalOnBean(MarkerConfiguration.Marker.class)
@ConditionalOnProperty(prefix = BootstrapConfigProperties.PREFIX, value = "enable", matchIfMissing = true, havingValue = "true")
public class NacosCloudAutoConfiguration {

    @Bean
    public NacosCloudRefresherHandler nacosCloudRefresherHandler(BootstrapConfigProperties properties,
                                                                 NotifierDispatcher notifierDispatcher) {
        return new NacosCloudRefresherHandler(properties, notifierDispatcher);
    }
}